
#include "InputLine.h"
#include <map>

using namespace std;

class Analyser
{
public:
	//*************************************************************************
	//Constructor from Parser object
	//*************************************************************************
	Analyser(const InputLine& inp);

	//*************************************************************************
	//copy CTOR
	//*************************************************************************
	Analyser(const Analyser& anl);

	//*************************************************************************
	//assignment operator
	//*************************************************************************
	const Analyser& operator=(const Analyser& anl);

	//*************************************************************************
	//Check the syntax and report mistakes
	//*************************************************************************
	virtual void doAnalyse();

	//*************************************************************************
	//DTOR
	//*************************************************************************
	~Analyser(void);

protected:
	//*************************************************************************
	//Checking first rule violation (brackets) before the end of the line
	//*************************************************************************
	virtual void checkBracketsA(const string token, int lineNum);

	//*************************************************************************
	//Checking first rule violation (brackets)  - opened==closed 
	//*************************************************************************
	virtual void checkBracketsB() const;

	//*************************************************************************
	//Checking second rule (if-else)
	//*************************************************************************
	virtual void checkIfElse(const string token, int lineNum);

	//*************************************************************************
	//Checking third rule violation (multiple predefined types)   
	//*************************************************************************
	virtual void checkMultiplePredefined(const string token, int lineNum);

	//*************************************************************************
	//checking identifier second rule(token wasn't declared before)  
	//*************************************************************************
	virtual void checkIdentifierDeclare(const string token,const string prev, int lineNum);

	//*************************************************************************
	//Checking fourth rule violation (already declared)   
	//*************************************************************************
	virtual void checkAlreadyDeclared(const string token, int lineNum);



	

private:

	InputLine inputLine;  // class with container of tokens ready for analysis

	static const int ARRAY_SIZE = 16;
	static const string PRESERVED[ARRAY_SIZE];
	static const string ALPHABETIC;

	map <string , int> declaration; //container that store declared veriable

	int rBrackets;        // counter for round brackets
	int sBrackets;        // counter for square brackets
	int cBrackets;        // counter for curly brackets
	int ifElse;           // counter for if-else rule
	int multiple;         // counter for multiplePredefined rule
};
